package com.smartpro.mis.modular.system.dao;

import com.smartpro.mis.modular.business.neo4jEntity.BuyNotPayRelationship;
import com.smartpro.mis.modular.business.neo4jEntity.DistributorExpireRelationship;
import com.smartpro.mis.modular.business.neo4jEntity.GroupBuyRelationship;
import com.smartpro.mis.modular.business.neo4jEntity.N4jUser;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

import java.util.Collection;

/**
 * @author Mengiy
 */
@RepositoryRestResource(collectionResourceRel = "groupBuyRelationship", path = "groupBuyRelationship")
public interface GroupBuyRelationRepository extends Neo4jRepository<GroupBuyRelationship, Long> {
    GroupBuyRelationship findByGroupBuyLeader(@Param("n4jUser") N4jUser n4jUser);

    @Query("MATCH (m:N4jUser)-[r:groupBuyRelationship]->(a:N4jUser) where m.userID = {userID} RETURN a")
    Collection<N4jUser> graph(@Param("userID") int userID);

}